package com.medical.admin.patient.controller;

import com.medical.admin.patient.common.dto.LogisticsDto;
import com.medical.admin.patient.service.LogisticsService;
import com.qf.medical.response.ResponseEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * 1.添加物流信息
 * 2.删除物流信息
 * 3.修改物流信息
 * 4.查询物流信息
 * 5.查询配送详情
 */
@Api(tags = "物流信息api在线文档")
@RestController
@RequestMapping("/logistics")
public class LogisticsController {
    @Resource
    private LogisticsService logisticsService;

    @ApiOperation("添加物流信息")
    @PostMapping("/addLogistics")
    @ApiImplicitParam(name = "logisticsDto",value = "物流信息Dto类")
    public ResponseEntity<Integer> addLogistics(@NotNull @RequestBody LogisticsDto logisticsDto) {
        return ResponseEntity.success(logisticsService.addLogistics(logisticsDto));
    }

    @ApiOperation("删除物流信息")
    @DeleteMapping("/removeLogistics")
    @ApiImplicitParam(name = "logisticsId",value = "物流单号id")
    public ResponseEntity<Integer> removeLogistics(@NotNull Long logisticsId) {
        return ResponseEntity.success(logisticsService.removeLogistics(logisticsId));
    }

    @ApiOperation("修改物流信息")
    @PutMapping("/modifyLogistics")
    @ApiImplicitParam(name = "logisticsDto",value = "物流信息Dto类")
    public ResponseEntity<Integer> modifyLogistics(@NotNull@RequestBody LogisticsDto logisticsDto) {
        return ResponseEntity.success(logisticsService.modifyLogistics(logisticsDto));
    }

    @ApiOperation("查询物流信息")
    @GetMapping("/searchLogistics")
    @ApiImplicitParam(name = "patientId",value = "患者id")
    public ResponseEntity<LogisticsDto> searchLogistics(@NotNull Long patientId) {
        return ResponseEntity.success(logisticsService.searchLogistics(patientId));
    }

    @ApiOperation("查询配送详情")
    @GetMapping("/detailLogistics")
    @ApiImplicitParam(name = "patientId",value = "患者id")
    public ResponseEntity<LogisticsDto> detailLogistics(@NotNull Long patientId) {
        return ResponseEntity.success(logisticsService.detailLogistics(patientId));
    }

}
